package org.dtrd.modules.shop.entity.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.config.pay.OrderUtil;
import org.dtrd.modules.shop.entity.bean.ProductDetail;


/**
 * <p>
 * 
 * </p>
 *
 * @author sun
 * @since 2022-07-23
 */
@Getter
@Setter
@TableName("dtrd_ent_shc_rd_product")
public class DtrdEntShcRdProduct {

    @TableId(value = "data_id", type = IdType.AUTO)
    private Integer dataId;

    @TableField("is_del")
    @TableLogic
    private Integer isDel;

    /**
     * 1-监测设备，2-试纸，3-服务，4-营养餐包
     */
    @TableField("product_category")
    private Integer productCategory;

    /**
     * 商品名称
     */
    @TableField("product_name")
    private String productName;

    /**
     * 商品价格
     */
    @TableField("product_price")
    private Integer productPrice;

    /**
     * 商品折扣价
     */
    @TableField("product_discount_price")
    private Integer productDiscountPrice;

    /**
     * 商品信息
     */
    @TableField("product_info")
    private String productInfo;

    /**
     * 商品缩略图
     */
    @TableField("product_thumb")
    private String productThumb;

    /**
     * 商品入口图
     */
    @TableField("product_enter_pic")
    private String productEnterPic;

    /**
     * 商品滚动图
     */
    @TableField("product_banner")
    private String productBanner;

    /**
     * 商品详情图
     */
    @TableField("product_detail_pic")
    private String productDetailPic;

    /**
     * 商品对应服务包ID
     */
    @TableField("product_service_id")
    private Integer productServiceId;

    /**
     * 排序
     */
    @TableField("product_sort")
    private Integer productSort;

    /**
     * 商品状态：0-下架，1-上架
     */
    @TableField("product_status")
    private Integer productStatus;

    /**
     * 库存
     */
    @TableField("product_stock")
    private Integer productStock;

    /**
     * 创建时间
     */
    @TableField("create_time")
    private Date createTime;

    @TableField("org_code")
    private String orgCode;

    @TableField("product_sku")
    private String productSku;

    @TableField("product_unit")
    private String productUnit;

    @TableField("product_vip_price")
    private Integer productVipPrice;

    @TableField("product_tag")
    private String productTag;

    @TableField("product_is_hot")
    private Integer productIsHot;

    @TableField("product_push_time")
    private Date productPushTime;

    public DtrdEntShcRdProduct init() {
        isDel = 0;
        createTime = new Date();
        return this;
    }

    public DtrdEntShcRdProduct parseFromDto(ProductDetail dto) {
        dataId = dto.getDataId();
        productCategory = dto.getProductCategory();
        productName = dto.getProductName();
        productPrice = OrderUtil.changeY2F(dto.getProductPrice());
        productDiscountPrice = OrderUtil.changeY2F(dto.getProductDiscountPrice());
        productVipPrice = OrderUtil.changeY2F(dto.getProductVipPrice());
        productInfo = dto.getProductInfo();
        productThumb = dto.getProductThumb();
        productEnterPic = dto.getProductEnterPic();
        productBanner = dto.getProductBanner();
        productDetailPic = dto.getProductDetailPic();
        productServiceId = dto.getProductServiceId();
        productSort = dto.getProductSort();
        productStatus = dto.getProductStatus();
        productStock = dto.getProductStock();
        orgCode = dto.getOrgCode();
        productUnit = dto.getProductUnit();
        productSku = dto.getProductSku();
        productTag = dto.getProductTag();
        productIsHot = dto.getProductIsHot();
        return this;
    }


}
